package com.foreknow.mapping;

import java.util.HashMap;
import java.util.Map;

public class MappingFactory {
    private static MappingFactory mappingFactory=null;
    private Map<String,EntityMapping> maps =new HashMap<>();
    public static final String GUESTBOOK_MAPPING="guestbookmapping";
    public static final String ADMIN_MAPPING="adminmapping";
    private MappingFactory(){

    }
    public static MappingFactory getInstance(){
        if (mappingFactory==null){
            mappingFactory=new MappingFactory();
            //向Map中保存xxxMapping对象
            mappingFactory.maps.put(GUESTBOOK_MAPPING,new GuestbookMapping());
            mappingFactory.maps.put(ADMIN_MAPPING,new AdminMapping());
            //mappingFactory.maps.put("xxxmapping",new xxxMapping());
        }
            return mappingFactory;
    }
    public EntityMapping getMap(String key){
        return maps.get(key);
    }
}
